package com.example.demo.controller;

import com.example.demo.service.LogService;
import com.example.demo.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Home-pc
 * Date: 2024-02-24
 * Time: 20:05
 */

@Slf4j
@RequestMapping("/proga")
@RestController
public class ProController {

    @Autowired
    private UserService userService;

    @Autowired
    private LogService logService;

    @Transactional
    @RequestMapping("/p1")
    public String p1(String userName,String password){
        Integer result = userService.insertUser(userName,password);
        log.info("用户插入成功");

        Integer result2 = logService.insertLog(userName,"用户注册");
        log.info("日志插入成功");

        return "注册成功";
    }
}
